/**
 * Created by Administrator on 2017/3/14.
 */
var RealName = require('../../src/complex/realName');
var BankCard = require('../../src/complex/bankCard');
var AddBankCard = require('../../src/complex/addBankCard');
var Root = React.createClass({
    getInitialState: function () {
      return {
          realName:PageDM.realNameInfo.value,
          cardlist:PageDM.cardList.value
      }
    },
    componentDidMount: function(){
        var _this = this;
        UEventHub.on(PageDM.realNameInfo.dmbind + UI_EVENT_CONST.SET_UDM_VALUE_EVENT, function(v){
            _this.updateRealNameInfoHandler(v);
        });
        UEventHub.on(PageDM.cardList.dmbind + UI_EVENT_CONST.SET_UDM_VALUE_EVENT, function(v){
            _this.updateCardListHandler(v);
        });
        UEventHub.emit("pageLoad","hello world!");
    },
    updateRealNameInfoHandler: function (v) {
        var _this = this;
       _this.refs.realName.setState({
           data:v
       });
    },
    _handleClick: function (e) {
        var _this = this;
        PageDM.aclayer.showDialog(_this);
    },

    delBankCardHandler: function (item) {
        var _this = this;
        PageDM.cardList.delclick(item.UserBankAccountId)

    },

	updateCardListHandler: function (v) {
        var _this = this;
        _this.refs.bankcard.setState({
            data:v
        })
        // _this.setState({
        //     cardlist:v
        // })


    },
    render: function () {
        var _this = this;
        var PageDM = window.PageDM;

        return (
            <div>

                <div className="mod-account container">
                    <div className="sub-nav">
                        <RealName ref="realName" data={PageDM.realNameInfo.value}/>
                    </div>
                    <div className="account padding">
                        <div className="bank-card">
                            <div className="title-account"><span>我的银行卡</span></div>
                            <div className="tips fc-main"><i className="iconfont icon-tips"></i> （温馨提示：该账户用于接收回款的本金和利息）</div>
                            <div className="list clearfix" ref="cardList">
                                <BankCard ref="bankcard" data={PageDM.cardList.value}/>
                                <AddBankCard data={PageDM.url.addBankCard}/>
                            </div>
                        </div>
                    </div>
                    <div className="clear"></div>
                </div>

            </div>
        )
    }
});
ReactDOM.render(<Root/>, document.getElementById('giraffe'));